<%@ page contentType="text/html;charset=UTF-8" language="java"  import="java.util.*" trimDirectiveWhitespaces="true" %>
<%@include file="/WEB-INF/pages/common/taglib.jsp"%>

<head>
  <title>微信用户登录 </title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <%@include file="/WEB-INF/pages/common/commonCss.jsp"%>
  <link rel="stylesheet" href="${basePath}/resources/css/matrix-login.css" />
  <link rel="stylesheet" href="${basePath}/resources/weixin/public/login.css" />
  <%@include file="/WEB-INF/pages/weixin/common/common.jsp"%>


</head>

<body>
<div id="loginbox">
  <form id="loginform" class="form-vertical" action="">
    <div class="logo"><img src="${basePath}/resources/weixin/Images/platform_logo.png"></div>
    <div class="control-group">
        <div class="controls">
          <div class="main_input_box">
            <span class="add-on bg_lg"><i class="iconfont icon-phone"></i></span>
            <input type="text"  id="account" autocomplete="off" autofocus="autofocus" maxlength="60" placeholder="请输入11位手机号码" />
          </div>
        </div>
    </div>
    <div class="control-group">
      <div class="controls">
        <div class="main_input_box">
          <span class="add-on bg_ly"><i class="iconfont icon-lock"></i></span>
          <input type="password" id="password" autocomplete="off" placeholder="请输入密码..." />
        </div>
      </div>
    </div>

    <div class="control-group">
      <div class="controls">
        <div class="main_input_box">
          <a  href="javascript:void(0);" onclick="tz_login(this)" class="submit">登陆</a></span>
         </div>
      </div>
    </div>

    <div class="control-group">
      <div class="controls">
        <div class="main_input_box memo" >
          <span class="pull-left"><a href="#" id="to-recover"><i class="iconfont icon-wenhao "></i>忘记密码</a></span>
          <span class="pull-right"><a href="${basePath}/weixin/register" ><i class="iconfont icon-register"></i>我要注册</a></span>
        </div>
      </div>
    </div>


  </form>

</div>

<%@include file="/WEB-INF/pages/common/commonJS.jsp"%>
<script type="text/javascript" src="${basePath}/resources/js/matrix.login.js"></script>


<script>
  $(function(){
    $(document).keydown(function(e){
      if(e.keyCode==13){
        tz_login();
      }
    });

    $("#account").keyup(function(){
      tzMap.put("weixin_account",$(this).val(),1);
    });

    var username = tzMap.get("weixin_account",1);
    if(username)$("#account").val(username);

  });


  function tz_login(obj){
    var account = $("#account").val();
    var password = $("#password").val();
    var params = {phone:account,password:password};
    if(isEmpty(account)){
      loading("请输入账号",4);
      $("#account").focus();
      return;
    }
    if(isEmpty(password)){
      loading("请输入密码",4);
      $("#password").focus();
      return;
    }

    $(obj).removeAttr("onclick").text("登陆中....");
    tzAjax.request({
      url:basePath+"/weixin/logined",
      error:function(){$(obj).attr("onclick","tz_login(this)").text("登陆中");},
      success:function(data){
        console.log(JSON.stringify(data));
        $(obj).attr("onclick","tz_login(this)").text("登陆中");
        if(data.code=="error" || data.code=="null"){
          loading("请填写账号或者密码...",4);
          $("#password").val("");
          $("#account").select();
        }else if(data.code=="fail"){
          loading("请输入正确账号和密码!!!" ,4);
            $("#password").val("");
            $("#account").select();
            $(obj).text("登陆");
        }else if(data.code=="forbiden"){
          $("#password").val("");
          $("#account").select();
          loading("您的账号已被禁止...",4);
        }else if(data.code=="success"){
          //登陆成功
          localStorage.setItem("jinlele_user",JSON.stringify(data.user));
          return;
          var refer = document.referrer;
          //登陆成功
          window.location.href = isNotEmpty(refer) ? refer: basePath+"/";
        }
      }
    },params);
//                $.ajax({
//                    type:"post",
//                    url:basePath+"/logined",
//                    data:params,
//                    success:function(data){
//                        if(data=="error" || data=="null"){
//                            loading("请填写账号或者密码..." , 3);
//                            $("#password").val("");
//                            $("#account").select();
//                        }else if(data=="fail"){
//                            //账号或者密码输入错误
//                            $("#password").val("");
//                            $("#account").select();
//                            loading("请输入正确的账号和密码!!!" ,3);
//                        }else if(data=="forbiden"){
//                            $("#password").val("");
//                            $("#account").select();
//                            loading("您的账号已被禁止...",3);
//                        }else{
//                            //登陆成功
//                            window.location.href = adminPath+"/index";
//                        }
//                    }
//                });
  };
</script>
</body>

</html>
